package com.nail.api.customMake.dao;


import com.nail.api.customMake.bean.Indent;
import com.nail.dao.IBaseDao;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface IIndentDao extends IBaseDao<Indent> {
	
	@Update("update indent set is_sort = #{sort} where order_id = #{orderId}")
	public void setSort(@Param("orderId")String orderId,@Param("sort") Integer sort);
	
	
	@Select("select * from indent where user_id = #{userId}  order by is_sort desc,create_time desc limit #{start},#{end}")
	public List<Indent> getIndentByUserId(@Param("userId")Long userId, @Param("start")Integer start, @Param("end")Integer end);

	@Select("select count(1) as num from indent where user_id = #{userId}")
	public Integer getIndentByUserIdCount(@Param("userId")Long userId);

	@Select("select count(1) as num from indent")
	public Integer getIndentCountAll();

    @Select("select * from indent order by is_sort desc,create_time desc limit #{start},#{end}")
    public List<Indent> getIndent(@Param("start")Integer start,@Param("end")Integer end);


    @Delete("delete from indent where user_id = #{userId} and order_id = #{orderId}")
    public void deleteByUserIdAndOrderId(@Param("orderId")String orderId,@Param("userId") Long userId);

	@Select("select * from indent where order_id = #{orderId}")
	public Indent getIndentByOrderId(@Param("orderId")String orderId);
	
	@Select("select * from indent where order_id = #{orderId} and user_id = #{userId}")
	public Indent getIndentByOrderIdAndUserId(@Param("orderId")String orderId,@Param("userId")Long userId);
	
	@Update("#{sql}")
	public void changeState(@Param("sql")String sql);
	
	@Update("update indent set is_down = 1 where order_id = #{orderId}")
	public void setIsDown(@Param("orderId")String orderId);

	@Update("update indent set pay_status = #{payStatus},update_time = now() where order_id = #{orderId} and user_id = #{userId}")
	public void changePayState(@Param("userId")Long userId,@Param("orderId")String orderId,@Param("payStatus")Integer payStatus);
}
